package org.example.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import dev.langchain4j.model.chat.ChatLanguageModel;
import dev.langchain4j.model.chat.StreamingChatLanguageModel;
import dev.langchain4j.service.AiServices;

@Configuration
class AiConfiguration {

    @Autowired
    private StreamingChatLanguageModel streamingModel;

    @Bean
    public AssistantApi assistantApi(ChatLanguageModel chatModel, AssistantProperties properties) {
        return AiServices.builder(AssistantApi.class)
                .streamingChatLanguageModel(streamingModel)
                .systemMessageProvider(input -> properties.getSystemPrompt())
                .build();
    }

}
